#include<iostream>
using namespace std;
#include<vector>
class Solution {
public:
    int totalFruit(vector<int>& fruits) {
        int hash[100000] = { 0 };
        int left = 0;
        int right = 0;
        int num = fruits.size();
        int n = 0;
        int max = 0;
        while (right < num) {
            if ((++hash[fruits[right++]]) == 1) {
                n++;
            }
            while (n > 2) {
                if ((--hash[fruits[left++]]) == 0) {
                    n--;
                }
            }
            if (max < right - left) {
                max = right - left;
            }
        }
        return max;
    }
};
int main()
{
    cout << "hui" << endl;
	return 0;
}